package com.cskaoyan.service.wx;

import com.cskaoyan.bean.MarketCategory;
import com.cskaoyan.bean.vo.wx.catalog.CatalogVo;
import com.cskaoyan.mapper.MarketCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: zhang
 * @Date: 2022/11/22 20:34
 * @Since: jdk1.8
 */
@Service
public class WxCatalogServiceImpl implements WxCatalogService {
    @Autowired
    MarketCategoryMapper marketCategoryMapper;

    @Override
    public CatalogVo current(Integer id) {
        MarketCategory category = marketCategoryMapper.selectByPrimaryKey(id);
        List<MarketCategory> categoryList = marketCategoryMapper.selectAllCategoriesByLevel1(id);
        return new CatalogVo(category, categoryList);
    }

    @Override
    public CatalogVo index() {
        MarketCategory indexCategory = marketCategoryMapper.selectIndexCategory();
        List<MarketCategory> categories = marketCategoryMapper.selectAllCategoriesByLevel1(indexCategory.getId());
        return new CatalogVo(indexCategory, categories);
    }
}
